package io.github.jsp.tranvolume.dto;

import java.util.List;

/**
 * API响应结果封装
 */
public class Result<T> {
    
    private boolean success;
    private String message;
    private T data;

    private Result(boolean success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(true, "操作成功", data);
    }

    public static <T> Result<T> success(String message, T data) {
        return new Result<>(true, message, data);
    }

    public static <T> Result<T> error(String message) {
        return new Result<>(false, message, null);
    }

    // Getters
    public boolean isSuccess() { return success; }
    public String getMessage() { return message; }
    public T getData() { return data; }
}

/**
 * 省份环比数据DTO
 */
class ProvinceCompareData {
    private String provCode;
    private String provName;
    private List<TimeSeriesData> currentData;
    private List<TimeSeriesData> historyData;
    private double compareRate;

    // Getters and Setters
    public String getProvCode() { return provCode; }
    public void setProvCode(String provCode) { this.provCode = provCode; }
    
    public String getProvName() { return provName; }
    public void setProvName(String provName) { this.provName = provName; }
    
    public List<TimeSeriesData> getCurrentData() { return currentData; }
    public void setCurrentData(List<TimeSeriesData> currentData) { this.currentData = currentData; }
    
    public List<TimeSeriesData> getHistoryData() { return historyData; }
    public void setHistoryData(List<TimeSeriesData> historyData) { this.historyData = historyData; }
    
    public double getCompareRate() { return compareRate; }
    public void setCompareRate(double compareRate) { this.compareRate = compareRate; }
}

/**
 * 时间序列数据DTO
 */
class TimeSeriesData {
    private String time;
    private Integer value;
    private Double successRate;

    public TimeSeriesData() {}

    public TimeSeriesData(String time, Integer value, Double successRate) {
        this.time = time;
        this.value = value;
        this.successRate = successRate;
    }

    // Getters and Setters
    public String getTime() { return time; }
    public void setTime(String time) { this.time = time; }
    
    public Integer getValue() { return value; }
    public void setValue(Integer value) { this.value = value; }
    
    public Double getSuccessRate() { return successRate; }
    public void setSuccessRate(Double successRate) { this.successRate = successRate; }
}

/**
 * 中心监控数据DTO
 */
class CenterMonitorData {
    private String center;
    private String centerName;
    private List<TimeSeriesData> volumeData;
    private List<TimeSeriesData> successRateData;
    private Integer currentVolume;
    private Double currentSuccessRate;

    // Getters and Setters
    public String getCenter() { return center; }
    public void setCenter(String center) { this.center = center; }
    
    public String getCenterName() { return centerName; }
    public void setCenterName(String centerName) { this.centerName = centerName; }
    
    public List<TimeSeriesData> getVolumeData() { return volumeData; }
    public void setVolumeData(List<TimeSeriesData> volumeData) { this.volumeData = volumeData; }
    
    public List<TimeSeriesData> getSuccessRateData() { return successRateData; }
    public void setSuccessRateData(List<TimeSeriesData> successRateData) { this.successRateData = successRateData; }
    
    public Integer getCurrentVolume() { return currentVolume; }
    public void setCurrentVolume(Integer currentVolume) { this.currentVolume = currentVolume; }
    
    public Double getCurrentSuccessRate() { return currentSuccessRate; }
    public void setCurrentSuccessRate(Double currentSuccessRate) { this.currentSuccessRate = currentSuccessRate; }
}

/**
 * 失败码统计数据DTO
 */
class FailCodeData {
    private String retCode;
    private String retDesc;
    private Integer failCount;
    private Double failRate;

    public FailCodeData() {}

    public FailCodeData(String retCode, String retDesc, Integer failCount, Double failRate) {
        this.retCode = retCode;
        this.retDesc = retDesc;
        this.failCount = failCount;
        this.failRate = failRate;
    }

    // Getters and Setters
    public String getRetCode() { return retCode; }
    public void setRetCode(String retCode) { this.retCode = retCode; }
    
    public String getRetDesc() { return retDesc; }
    public void setRetDesc(String retDesc) { this.retDesc = retDesc; }
    
    public Integer getFailCount() { return failCount; }
    public void setFailCount(Integer failCount) { this.failCount = failCount; }
    
    public Double getFailRate() { return failRate; }
    public void setFailRate(Double failRate) { this.failRate = failRate; }
}